package com.glacier.demo.config;

import com.alibaba.csp.sentinel.annotation.aspectj.SentinelResourceAspect;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.glacier.demo.handle.GlobalBlockExceptionHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * date 2024-01-29 21:38
 *
 * @author glacier
 * @version 1.0
 */
@Configuration
public class SentinelAspectConfiguration {
    /**
     * 注册sentinel资源切面
     *
     * @return sentinel资源切面
     */
    @Bean
    SentinelResourceAspect sentinelResourceAspect() {
        return new SentinelResourceAspect();
    }

    /**
     * 注册全局异常处理
     *
     * @param objectMapper objectMapper
     * @return 全局异常处理
     */
    @Bean
    GlobalBlockExceptionHandler globalBlockExceptionHandler(ObjectMapper objectMapper) {
        return new GlobalBlockExceptionHandler(objectMapper);
    }
}
